<?php
define('DS', DIRECTORY_SEPARATOR);
$dirs = explode(DS, $root);
$path = '';
?>
<ul class="breadcrumb">
    <li><a href="?root=">root</a> <span class="divider">/</span></li>
    <?php foreach ($dirs as $dir): ?>
    <?php if ($dir == '') continue; ?>
    <?php $path .= $dir; ?>
    <li><a href="?root=<?php echo $path; ?>"><?php echo $dir; ?></a> <span class="divider">/</span></li>
    <?php $path .= DS; ?>
    <?php endforeach; ?>
    <li class="active"><?php echo $file; ?></li>
</ul>
    
<?php if ($mime == 'image' ): ?>
<img src="?getfile=<?php echo $root . DS . $file; ?>" />
<?php elseif ($mime == 'text' ): ?>
<form method="post">
    <input type="hidden" name="action" value="saveContent" />
    <fieldset>
        <legend>Edit file</legend>
        <div class="clearfix">
            <label>Content</label>
            <div class="input">
                <?php echo Form::textarea('content', file_get_contents(realpath(DOCROOT . '..' . DS . $root . DS . $file)), array(
                    'class' => 'span11',
                    'style' => 'height: 500px;'
                )); ?>
            </div>
        </div>
        <div class="actions">
            <button class="btn primary" type="submit">Save changes</button>
        </div>
    </fieldset>
</form>
<?php endif; ?>